<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head>
    <#include "/common/elibs.html">
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
</head>
<script>
</script><body>
<div class="x-body">
    <form class="layui-form">
        <input type="hidden" name="idProAdmin" id="idProAdmin" value="${id}"/>
        <input type="hidden" name="idProUserEvaluation" id="idProUserEvaluation" />
        <div class="layui-form-item">
            <label for="customerEvaluation" class="layui-form-label">

                <span class="x-red">*</span>客户满意度评价表：<br/>
                注：涵盖格式有（word，pdf，jpg）

            </label>
            <div class="layui-input-inline">
                <a><img src="" id="imgUrl" width="100px"/></a>
                <br><br><br>
                <input type="hidden" id="customerEvaluation" name="customerEvaluation"  >
                <button type="button" class="layui-btn" id="upload">
                    <i class="layui-icon">&#xe67c;</i>上传文件
                </button><script>
                updateFile("upload","imgUrl","customerEvaluation");
            </script>

            </div>
        </div>

        <div class="layui-form-item" id="submitButton">
            <label for="customerEvaluation" class="layui-form-label">
            </label>
            <button  class="layui-btn" lay-filter="preservation" type=button codeTyle="1" lay-submit="">
                保存
            </button>
            <button  class="layui-btn" lay-filter="preAdd" type=button codeTyle="2" lay-submit="">
                预提交
            </button>
            <button  class="layui-btn" lay-filter="add" type=button codeTyle="3" lay-submit="">
                提交
            </button>
        </div>
        <div class="layui-form-item" id="updateStart">
            <label for="customerEvaluation" class="layui-form-label">
            </label>
            <button  class="layui-btn" lay-filter="update" type=button codeTyle="0" lay-submit="">
                修改
            </button>
        </div>
    </form>
</div>
<script>

    $(function(){
        var index = 44;
        ajaxFun('get','/pc/project/getUserEvaluationInfo',{"idProAdmin":$("#idProAdmin").val()},function(data){
            if(data.code != 0){
                alertOpen("提示信息",data.message);
            }else{
                if(data.data.submitState === 3){
                    $("#submitButton").hide();
                    $("#updateStart").show();
                }else{
                    $("#submitButton").show();
                    $("#updateStart").hide();
                }
                $("#idProUserEvaluation").val(data.data.idProUserEvaluation);
                $("#imgUrl").attr("src",getIos(data.data.customerEvaluationSuffixName,data.data.customerEvaluationFilePath));
                $("#imgUrl").parent().attr("href",data.data.customerEvaluationFilePath);
                $("#customerEvaluation").val(data.data.customerEvaluation);
            }
        })
    })
    layui.use(['form','layer'], function() {
        $ = layui.jquery;
        var form = layui.form
            , layer = layui.layer, layedit = layui.layedit;

        //自定义验证规则
        form.verify({});

        //监听提交
        form.on('submit(add)', function (t) {
            addSubmit(3);
        });

        //监听保存
        form.on('submit(preservation)', function (t) {
            addSubmit(1);
        });

        //监听预提交
        form.on('submit(preAdd)', function (t) {
            addSubmit(2);
        });

        //修改
        form.on('submit(update)', function (t) {
            addSubmit(10);
        });
    });

    function addSubmit(submitState){
        var params = {
            //tcaDescribe : layui.layedit.getContent(index),
            "idProUserEvaluation": $("#idProUserEvaluation").val(),
            "idProAdmin": $("#idProAdmin").val(),
            "customerEvaluation": $("#customerEvaluation").val(),
            "submitState":submitState
        }
        console.log(params);
        if (true) {
            ajaxFun('post','/pc/project/updateUserEvaluation',params,function(data){
                if (data.code != 0) {
                    alertFun(data);
                } else {
                    window.location.href = path + "/modules/project/yhpjgz/list.html";
                    console.log("success !");
                }
            })
            return false;
        }
    }
</script></body></html>